﻿package com.atn.edamame.googlews {
  import flash.errors.IllegalOperationError;
  import flash.net.*; 
  import org.flashdevelop.utils.FlashConnect;
  import com.atn.edamame.EdamameConfig;
  public class GConnection {
    private static var instance:GConnection = null;
    private static var internallyCalled:Boolean = false;
	private var netConnection:NetConnection = new NetConnection();
    public function GConnection() {
      if (internallyCalled) {
		netConnection.connect(EdamameConfig.getInstance().getPyamfGateway());
        internallyCalled = false;
      } else {
        throw new IllegalOperationError ("Use Singleton.getInstance() to get the instance");
      }
    }

    public static function getInstance():GConnection {
      if(GConnection.instance == null) {
        internallyCalled = true;
        instance = new GConnection();
      }
      return instance;
    }
	
	public function getConnection() :NetConnection{
		return netConnection;
	}
	
  }
	
}